﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Project.aspx.cs" Inherits="Main_Master_Project" %>

<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Src="~/User Controls/CommonControls.ascx" TagName="CommonControls" TagPrefix="MyControls" %>
<%@ Register Src="~/User Controls/Pager.ascx" TagPrefix="custom" TagName="Pager" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <link href="../../Styles/accounts.css" rel="Stylesheet" type="text/css" />
    <title></title>
    <script type="text/javascript">
        function hidemsg() {
            document.getElementById("lblMessage").style["display"] = "none";
        }
        function hideViewmsg() {
            document.getElementById("lblMsgView").style["display"] = "none";
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="divmain" align="center">
        <asp:Panel ID="pnlData" runat="server" Visible="false">
            <div style="margin-left: 1%; width:100%;">
                <acc:heading ID="header1" runat="server" HeadingText="Project" />
                <asp:Label ID="lblMessage" runat="server" style="display:none;"></asp:Label>
                <table cellpadding="0" cellspacing="0" class="tablecontent" width="60%">
                    <tr>
                        <td class="headtd" colspan="4">
                            Add Project
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" style="height:10px">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td style="width:25%;">
                            &nbsp;
                        </td>
                        <td style="width:15%;">
                            Project Name
                        </td>
                        <td style="width:35%;">
                            <asp:TextBox ID="txtproject" onFocus="hidemsg();" MaxLength="100" Width="200px" CssClass="input" runat="server"></asp:TextBox>
                        </td>
                        <td style="width:25%;">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                        </td>
                        <td>
                            <asp:Button ID="btnSaveproject" runat="server" Text=" Add Project " CssClass="button"
                                OnClick="btnSaveproject_Click" Width="100px" OnClientClick="return CheckValidation();" />
                                <script type="text/javascript">
                                    function CheckValidation()
                                    {
                                        if (document.getElementById("txtproject").value == '') 
                                        {
                                            document.getElementById("lblMessage").innerHTML = "Please Enter the Project Name.";
                                            document.getElementById("lblMessage").style["display"] = "block";
                                            document.getElementById("lblMessage").style["color"] = "#B90000";
                                            return false;
                                        }
                                    }
                                </script>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>                    
                </table>
            </div>
        </asp:Panel>
        <asp:Panel ID="pnlview" runat="server" Visible="false">
            <div>
                <acc:heading ID="pagehead" runat="server" HeadingText="Project View" />
            </div>
            <asp:Label ID="lblMsgView" runat="server" style="display:none;"></asp:Label>
            <div style="margin-left: 5%; background-color:#EEEEEE; margin-right:5%; height:24px;">                
                <table style="width:100%;" cellpadding="0" cellspacing="0">
                    <tr>                    
                        <td style="width:5%;">
                            &nbsp;&nbsp;&nbsp;<asp:ImageButton ID="imgpdf" ToolTip="Export To PDF" runat="server" ImageUrl="~/Images/PDF.png" OnClick="imgpdf_Click" />&nbsp;
                        </td>
                        <td style="width:5%;">
                            &nbsp;&nbsp;&nbsp;<asp:ImageButton ID="imgword" ToolTip="Export To Word" runat="server" ImageUrl="~/Images/word_icon.png" OnClick="imgword_Click" />&nbsp;    
                        </td>
                        <td style="width:60%;">
                            &nbsp;&nbsp;&nbsp;<asp:ImageButton ID="imgxl" ToolTip="Export To Excel" runat="server" ImageUrl="~/Images/Excel.png" OnClick="imgxl_Click" />    
                        </td>
                        <td style="width:10%;">
                            Search
                        </td>
                        <td style="width:10%;">
                            <asp:TextBox ID="txtSearchProject" onFocus="hideViewmsg();" runat="server" Width="200px" CssClass="input" ></asp:TextBox>

                        </td>
                        <td style="width:10%;">
                            &nbsp;<asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="button" 
                                Width="80px" OnClientClick="return ValidationSearch();" 
                                onclick="btnSearch_Click" />
                            <script type="text/javascript">
                                function ValidationSearch() {
                                    if (document.getElementById("txtSearchProject").value == '') {
                                        document.getElementById("lblMsgView").innerHTML = "Please Enter the Search Criteria.";
                                        document.getElementById("lblMsgView").style["display"] = "block";
                                        document.getElementById("lblMsgView").style["color"] = "#B90000";
                                        return false;
                                    }
                                }
                            </script>
                        </td>
                    </tr>
                </table>
            </div>
            <asp:GridView ID="grdprojectview" runat="server" AutoGenerateColumns="False" AllowPaging="True"
                DataKeyNames="projectid" CssClass="gridview" Width="90%" OnPageIndexChanging="grdprojectview_PageIndexChanging"
                OnRowCancelingEdit="grdprojectview_RowCancelingEdit" OnRowEditing="grdprojectview_RowEditing"
                OnRowUpdating="grdprojectview_RowUpdating" OnRowCommand="grdprojectview_RowCommand" PageSize="25">
                <Columns>
                    <asp:TemplateField HeaderText="Sr.No" ItemStyle-Width="5%">
                        <ItemTemplate>
                            <%#Container.DataItemIndex + 1 %>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField ItemStyle-Width="85%">
                        <HeaderTemplate>
                             <table width="100%" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td>
                                        Project Name
                                    </td>
                                    <td>
                                        <asp:ImageButton ID="LinkButtonProjectName" runat="server" CommandName="Sort" CommandArgument="Projectname"
                                            ImageUrl="~/Images/sort.png" />
                                    </td>
                                </tr>
                            </table>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:Label ID="lblprojectname" Width="200px" runat="server" Text='<%#Bind("Projectname")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="txtprojectname" runat="server" CssClass="input" MaxLength="100" Width="70%" Text='<%#Bind("Projectname")%>'></asp:TextBox>
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Action"  ItemStyle-Width="10%">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                Text="Edit"></asp:LinkButton>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                                Text="Update" OnClientClick="return CheckUpdate();"></asp:LinkButton>
                                <script type="text/javascript">
                                    function CheckUpdate() {
                                        var f = document.getElementById("grdprojectview");
                                        for (var i = 0; i < f.getElementsByTagName("input").length; i++) {
                                            if (f.getElementsByTagName("input").item(i).type == "text") {
                                                if (f.getElementsByTagName("input").item(i).value == 0) {
                                                    document.getElementById("lblMsgView").innerHTML = "Please Enter the Data for Update.";
                                                    document.getElementById("lblMsgView").style["display"] = "block";
                                                    document.getElementById("lblMsgView").style["color"] = "#B90000";
                                                    f.getElementsByTagName("input").item(i).focus();
                                                    return false;
                                                }
                                            }
                                        }
                                    }
                            </script>
                            &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                                Text="Cancel"></asp:LinkButton>
                        </EditItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </asp:Panel>
    </div>
    </form>
</body>
</html>
